from main.process import Process
#from main.errors import NotAProcessError, OutOfBoundsError
    

#-----------------------------------------------------------------------#
#------------------CLASS IOQueue----------------------------------------#
#-----------------------------------------------------------------------#

class ProcessesQueue():
    def __init__(self):
        self.processes = []
        
    def append(self,aProcess):
        if(not isinstance(aProcess, Process)):
            print('Attempt ot add a no-Process element to a process queue')#raise NotAProcessError('Attempt ot add a no-Process element to a process queue')
        else:
            self.processes.append(aProcess)
        
    def pop(self,num):
        return self.processes.pop(num)
          
    def popTheLast(self):
        return self.processes.pop()
    
    def length(self):
        return len(self.processes)
    
    def get(self,anIndex):
        if(len(self.processes) < anIndex):
            print('Out of bounds getting an element in ProcessesQueue!')#raise OutOfBoundsError('Out of bounds getting an element in ProcessesQueue!')
        else:
            return self.processes[anIndex]
    
    def cut(self,aProcess):
        self.processes.remove(aProcess)
     
    
    def index(self,anObject):
        return self.processes.index(anObject)
    
    def contains(self,aProcess):
        return aProcess in self.processes
    
    def isEmpty(self):
        return len(self.processes) == 0
